package com.luzhikun.myshopping.dao.impl;

import com.luzhikun.myshopping.dao.UserDao;
import com.luzhikun.myshopping.domaim.User;
import com.luzhikun.myshopping.util.DBCPUtil;

import java.util.List;

/**
 * @Author Rookie Coder
 * @Description
 * @Date
 **/
public class UserDaoImpl implements UserDao {
    private DBCPUtil dbcpUtil =new DBCPUtil();
    /*
     * @Author liu-miss
     * @Description 登录方法
     * @Date 16:09 2021/7/12
     * @Param [username, password]
     * @return boolean
     **/
    @Override
    public List<User> userLogin(String username, String password) {

        String sql="select username, password from user where username= ? and password = ?";
        List<User> query = dbcpUtil.query(sql, User.class, username, password);
        return query;
    }

    /*
     * @Author liu-miss
     * @Description 用户注册方法
     * @Date 20:36 2021/7/12
     * @Param
     * @return
     **/

    public boolean userRegist(String username,String password){
        System.out.println(username);
        System.out.println(password);

        String sql = "insert into user value( ? , ?)";
        int update = dbcpUtil.update(sql,username,password);

        return update>0;
    }

}
